﻿using System;
using System.Management.Automation;
using System.Runtime.InteropServices;
using Microsoft.SharePoint.PowerShell;

namespace CodeCounsel.SharePoint2010.DigiD.Cmdlets
{
    [SPCmdlet(RequireLocalFarmExist = true, RequireUserFarmAdmin = true)]
    [Cmdlet(VerbsCommon.Get, "DigiDSettings")]
    public class GetDigiDSettingsCmdlet : SPCmdlet
    {
        [Parameter(Mandatory = false, Position = 0, ValueFromPipeline = true)]
        public DigiDSettingsPipeBind Identity { get; set; }

        protected override void InternalProcessRecord()
        {
            if (Identity != null)
            {
                WriteObject(Identity.Read());
            }
            else
            {
                foreach (var settings in DigiDService.Local.DigiDSettings)
                {
                    WriteObject(settings);
                }
            }
        }
    }
}
